/*
 * @Author: szx
 * @Date: 2022-03-26 12:44:24
 * @LastEditTime: 2022-03-26 12:56:35
 * @Description:
 * @FilePath: \leetcode\剑指offer\46\46.js
 */
/**
 * @param {number} num
 * @return {number}
 */
 var translateNum = function (num) {
    num = num.toString();
    const n = num.length;
    const dp = new Array(n + 1).fill(0);
    dp[0] = 1;
    dp[1] = 1;
    for (let i = 2; i <= n; i++) {
        if ((num[i - 1] <= '5' && num[i - 1] >= '0' && num[i - 2] == '2') || num[i - 2] == '1') {
            dp[i] = dp[i - 2] + dp[i - 1];
        } else {
            dp[i] = dp[i - 1];
        }
    }
    return dp[n];
};
